%eyelink2_behavioral_anaysis

clc
clear
close all
scnsize = get(0,'ScreenSize');
graph_suru=0;
all_file_names=[''];
eyelink.file_name=[];
eyelink.filenum=[];  
eyelink.subjectnum=[];
eyelink.quad=[];
eyelink.anti=[];
eyelink.peri=[];
eyelink.srt=[];
eyelink.rank_srt=[];
eyelink.error=[];
eyelink.delay=[];
eyelink.long=[];
eyelink.sac_thres=[];
srt_pro=[];
srt_anti=[];
srt_error=[];
srt_pro_peri=[];
srt_anti_peri=[];
srt_error_peri=[];
srt_pro_cent=[];
srt_anti_cent=[];
srt_error_cent=[];
srt_pro_pro  =[];
srt_anti_anti=[];
srt_anti_pro =[];
srt_pro_anti=[];

%cd 'C:\_bcoe\eyelink2_data\_C_DATA'
cd 'C:\Data\data_eyelink2\study_2\_C_data_ginny';
% folders = dir;
% fred=[];
% for i=1:length(folders)
%     fred(i)=isdir(folders(i).name) & length(folders(i).name)>2; 
% end
% folders(~fred)=[];
% clear fred;index=1;
files=dir('*c.mat')
for i=1:length(files)
    load(files(i).name);
        
    eyelink.file_name=[eyelink.file_name; C.name];    
    eyelink.filenum  =[eyelink.filenum;   i*ones(size(C.anti))];
    eyelink.anti     =[eyelink.anti;      C.anti];
    eyelink.peri     =[eyelink.peri;      C.peri];
    eyelink.srt      =[eyelink.srt;       C.srt'];
    eyelink.error    =[eyelink.error;     C.error'];
    eyelink.delay    =[eyelink.delay;     C.delay];
    eyelink.long     =[eyelink.long;      diff(C.timeb(:,1))>10000];
    eyelink.sac_thres=[eyelink.sac_thres; C.sac_thres'];
    
    eyelink.quad=[ eyelink.quad; C.quad'];
    fred=group_rank(C.srt(C.srt>0))';
    clear rank_srt;
    rank_srt(C.srt>0,:)=(fred(:,3)/max(fred(:,3))*100);
    eyelink.rank_srt=[eyelink.rank_srt; rank_srt];
    status(i/length(files));
end
index=0;
eyelink.subjectnum=eyelink.filenum*0;
temp=eyelink.file_name
subject=[]
while length(temp)>0
%for i = 1:length(eyelink.file_name);
    index=index+1;
    %[eyelink.file_name num2str(eyelink.file_name(:,1)==temp(1,1))  num2str(eyelink.file_name(:,2)==temp(1,2))];
    fred=find(eyelink.file_name(:,1)==temp(1,1) & eyelink.file_name(:,2)==temp(1,2));
    %eyelink.file_name(fred,:)
    eyelink.subjectnum(match(eyelink.filenum,fred)>0)=index;
    subject=[subject; temp(1,:)];
    temp(fred-min(fred)+1,:)=[];
end
status(-1);


[a b]=hist_b(eyelink.filenum(eyelink.long==0));
clear temp;
temp(length(eyelink.file_name))=0;
temp(b(a>1))=1;
eyelink2.file_name =eyelink.file_name(temp>0,:)
eyelink2.filenum   =eyelink.filenum(eyelink.long==0);    
eyelink2.subjectnum=eyelink.subjectnum(eyelink.long==0);  
eyelink2.quad      =eyelink.quad(eyelink.long==0);    
eyelink2.anti      =eyelink.anti(eyelink.long==0);    
eyelink2.peri      =eyelink.peri(eyelink.long==0);    
eyelink2.srt       =eyelink.srt(eyelink.long==0);    
eyelink2.rank_srt  =eyelink.rank_srt(eyelink.long==0);    
eyelink2.error     =eyelink.error(eyelink.long==0);    
eyelink2.delay     =eyelink.delay(eyelink.long==0);    
eyelink2.long      =eyelink.long(eyelink.long==0);    
eyelink2.sac_thres =eyelink.sac_thres(eyelink.long==0);   


eyelink2
eyelink.file_name(temp>0,:)=[];
eyelink.filenum(eyelink.long==0)=[]; 
eyelink.subjectnum(eyelink.long==0)=[];  
eyelink.quad(eyelink.long==0)=[];
eyelink.anti(eyelink.long==0)=[];  
eyelink.peri(eyelink.long==0)=[]; 
eyelink.srt(eyelink.long==0)=[];
eyelink.rank_srt(eyelink.long==0)=[];
eyelink.error(eyelink.long==0)=[];   
eyelink.delay(eyelink.long==0)=[]; 
eyelink.sac_thres(eyelink.long==0)=[];

eyelink.long(eyelink.long==0)=[];
eyelink
    
%this shows that the cut off for early srt should be 300ms
error_rate=[];
amount=[];
errors=floor(eyelink.error);
for i=100:25:1500
    error_rate(end+1)=(sum(errors(eyelink.srt>i & eyelink.srt<i+25)==3) + sum(errors(eyelink.srt>i & eyelink.srt<i+25)==1))/(sum(errors(eyelink.srt>i & eyelink.srt<i+25)==3) + sum(errors(eyelink.srt>i & eyelink.srt<i+25)==1) + sum(errors(eyelink.srt>i & eyelink.srt<i+25)==0));
    amount(end+1)=sum(eyelink.srt>i & eyelink.srt<i+25);
end
error_rate(isnan(error_rate))=.5;
fig(1),clf;hold on;
hplot(100:25:1500,amount/max(amount),'r');
hplot(100:25:1500,error_rate);
axis tight;
%this sets the cut off for early srt at 300ms
eyelink.error(eyelink.srt< 300)=eyelink.error(eyelink.srt< 300)+.4;
%this sets the cut off for late  srt at 1000ms
eyelink.error(eyelink.srt>1200)=eyelink.error(eyelink.srt>1200)+.4;


srt_pro  =eyelink.srt(eyelink.anti==0 & eyelink.error==0 );
srt_anti =eyelink.srt(eyelink.anti==1 & eyelink.error==0 );
srt_pro_error =eyelink.srt(eyelink.anti==0 & eyelink.error==3 );
srt_anti_error=eyelink.srt(eyelink.anti==1 & eyelink.error==3 );
fig(2);set(gcf,'name','population trial by trial pro v anti SRT ');
subplot(2,2,1);ttest_bcoe(srt_anti,srt_pro); title('srt-pro v srt-anti');
subplot(2,2,2);ttest_bcoe(srt_anti_error,srt_pro_error);title('srt-pro-error v srt-anti-error');
subplot(2,2,3);mann_whitney(srt_pro,srt_pro_error);title('srt-pro v srt-pro-error');
subplot(2,2,4);mann_whitney(srt_anti,srt_anti_error);title('srt-anti v srt-anti-error');

r_srt_pro  =eyelink.rank_srt(eyelink.anti==0 & eyelink.error==0 );
r_srt_anti =eyelink.rank_srt(eyelink.anti==1 & eyelink.error==0 );
r_srt_pro_error =eyelink.rank_srt(eyelink.anti==0 & eyelink.error==3 );
r_srt_anti_error=eyelink.rank_srt(eyelink.anti==1 & eyelink.error==3 );
fig(3);set(gcf,'name','population trial by trial pro v anti ranked SRT ');
subplot(2,2,1);mann_whitney(r_srt_anti,r_srt_pro); title('srt-pro v srt-anti');
subplot(2,2,2);mann_whitney(r_srt_anti_error,r_srt_pro_error);title('srt-pro-error v srt-anti-error');
subplot(2,2,3);mann_whitney(r_srt_pro,r_srt_pro_error);title('srt-pro v srt-pro-error');
subplot(2,2,4);mann_whitney(r_srt_anti,r_srt_anti_error);title('srt-anti v srt-anti-error');


srt_pro_peri  =eyelink.srt(eyelink.anti ==0 & eyelink.error==0 & eyelink.peri==1);
srt_anti_peri =eyelink.srt(eyelink.anti ==1 & eyelink.error==0 & eyelink.peri==1);
srt_error_peri=eyelink.srt(eyelink.error==3 & eyelink.peri ==1);
srt_pro_cent  =eyelink.srt(eyelink.anti ==0 & eyelink.error==0 & eyelink.peri==0);
srt_anti_cent =eyelink.srt(eyelink.anti ==1 & eyelink.error==0 & eyelink.peri==0);
srt_error_cent=eyelink.srt(eyelink.error==3 & eyelink.peri ==0);
fig(4);clf,set(gcf,'name','population trial by trial PERI v CENT (pro/anti/error)')
subplot(2,3,1),ttest_bcoe(srt_pro_peri,srt_pro_cent)
subplot(2,3,2),ttest_bcoe(srt_anti_peri,srt_anti_cent)
subplot(2,3,3),ttest_bcoe(srt_error_peri,srt_error_cent)
subplot(2,3,4),mann_whitney(srt_pro_peri,srt_pro_cent)
subplot(2,3,5),mann_whitney(srt_anti_peri,srt_anti_cent)
subplot(2,3,6),mann_whitney(srt_error_peri,srt_error_cent)

r_srt_pro_peri  =eyelink.rank_srt(eyelink.anti ==0 & eyelink.error==0 & eyelink.peri==1);
r_srt_anti_peri =eyelink.rank_srt(eyelink.anti ==1 & eyelink.error==0 & eyelink.peri==1);
r_srt_error_peri=eyelink.rank_srt(eyelink.error==3 & eyelink.peri ==1);
r_srt_pro_cent  =eyelink.rank_srt(eyelink.anti ==0 & eyelink.error==0 & eyelink.peri==0);
r_srt_anti_cent =eyelink.rank_srt(eyelink.anti ==1 & eyelink.error==0 & eyelink.peri==0);
r_srt_error_cent=eyelink.rank_srt(eyelink.error==3 & eyelink.peri ==0);
fig(5);clf,set(gcf,'name','population trial by trial PERI v CENT rank (pro/anti/error)')
subplot(2,3,1),ttest_bcoe(r_srt_pro_peri,r_srt_pro_cent)
subplot(2,3,2),ttest_bcoe(r_srt_anti_peri,r_srt_anti_cent)
subplot(2,3,3),ttest_bcoe(r_srt_error_peri,r_srt_error_cent)
subplot(2,3,4),mann_whitney(r_srt_pro_peri,r_srt_pro_cent)
subplot(2,3,5),mann_whitney(r_srt_anti_peri,r_srt_anti_cent)
subplot(2,3,6),mann_whitney(r_srt_error_peri,r_srt_error_cent)



% 1-back crap
fred=[0; (diff(eyelink.filenum))] % remember to remove comparisons between files
srt_pro_pro  =eyelink.srt([0; [fred(2:end)<1 & eyelink.anti(1:end-1)==0 & eyelink.anti(2:end)==0 & eyelink.error(2:end)==0]]>0 );
srt_anti_anti=eyelink.srt([0; [fred(2:end)<1 & eyelink.anti(1:end-1)==1 & eyelink.anti(2:end)==1 & eyelink.error(2:end)==0]]>0 );
srt_anti_pro =eyelink.srt([0; [fred(2:end)<1 & eyelink.anti(1:end-1)==1 & eyelink.anti(2:end)==0 & eyelink.error(2:end)==0]]>0 );
srt_pro_anti =eyelink.srt([0; [fred(2:end)<1 & eyelink.anti(1:end-1)==0 & eyelink.anti(2:end)==1 & eyelink.error(2:end)==0]]>0 );

fig(6),clf;set(gcf,'name','Eyelink2 - MEAN SRT Pro v Anti (1 back )')
subplot(2,1,1);hold on;axis([.5 2.5 550 650]);tickout; axis auto
ylabel('Saccadic Reaction Time')
xlim([.5 2.5]);
plot(2,mean(srt_pro_peri),'b');
plot(2,mean(srt_pro_cent),'b');
h=text(2,mean(srt_pro_peri),'peri');set(h,'color',[0 0 .2],'FontWeight','bold');
h=text(2,mean(srt_pro_cent),'cent');set(h,'color',[0.7 0.7 1],'FontWeight','bold');
hline(mean(srt_pro),[.5 .5 .8]);
h=text(2,mean(srt_pro),'pro');set(h,'color',[0 0 1],'FontWeight','bold');

plot(2,mean(srt_anti_peri),'r');
plot(2,mean(srt_anti_cent),'r');
h=text(2,mean(srt_anti_peri),'peri');set(h,'color',[.2 0 0],'FontWeight','bold');
h=text(2,mean(srt_anti_cent),'cent');set(h,'color',[1 0.7 0.7],'FontWeight','bold');
hline(mean(srt_anti),[.8 .5 .5]);
h=text(2,mean(srt_anti),'anti');set(h,'color',[ 1 0 0],'FontWeight','bold');

plot(1,mean(srt_pro_pro),'color',[0 0 1]);
plot(1,mean(srt_anti_pro),'color',[.5 0 1]);
plot(1,mean(srt_pro_anti),'color',[1 0 .5]);
plot(1,mean(srt_anti_anti),'color',[1 0 0]);
h=text(1,mean(srt_pro_pro),'pro->pro');set(h,'color',[0 0 1],'FontWeight','bold');
h=text(1,mean(srt_anti_pro),'anti->pro');set(h,'color',[.5 0 1],'FontWeight','bold');
h=text(1,mean(srt_pro_anti),'pro->anti');set(h,'color',[1 0 .5],'FontWeight','bold');
h=text(1,mean(srt_anti_anti),'anti->anti');set(h,'color',[1 0 0],'FontWeight','bold');

subplot(2,2,3);
ttest_bcoe(srt_anti,srt_pro);
subplot(2,2,4);
mann_whitney(srt_anti,srt_pro);







fig(7);clf;hold on;ylim([200 1200])
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
set(gcf,'Name','Subjects Saccadic Reaction Time');tickout;
Ylabel('Subjects Mean Saccadic Reaction Time')
a=[];b=[];
for i=1:max(eyelink.subjectnum)
    xlim([i-.5 i+.5]);
    vline(i);
    [cnt val]=hist_b(eyelink.srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 ),25);
    cnt_a=cnt/40;
    hplot_v(val,-cnt_a+i,'vb',i);
    [cnt val]=hist_b(eyelink.srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 ),25);
    cnt_a=cnt/40;
    hplot_v(val,cnt_a+i,'vr',i);
    a(end+1)=mean(eyelink.srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 ))
    b(end+1)=mean(eyelink.srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 ))
    hline(a(end),'b');
    hline(b(end),'r');
end
plot(a,'b');
plot(b,'r');
set(gca,'xtick',[1:12]);
set(gca,'xticklabel',subject(:,1:2));
axis auto;ylim([200 1200])

fig(9),clf,set(gcf,'Name','Population analysis by subject''s SRT & SRR');tickout;
subplot(1,2,1)
%ttest_bcoe(b,a)
mann_whitney(b,a)
fig(8);clf;hold on;ylim([200 1200])
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
set(gcf,'Name','Subjects Saccadic Reaction Rank');tickout;
Ylabel('Subjects Mean Saccadic Reaction Rank')
a=[];b=[];
for i=1:max(eyelink.subjectnum)
    xlim([i-.5 i+.5]);
    vline(i);
    [cnt val]=hist_b(eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 & eyelink.long==1),5);
    cnt_a=cnt/40;
    hplot_v(val,-cnt_a+i,'vb',i);
    [cnt val]=hist_b(eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 & eyelink.long==1),5);
    cnt_a=cnt/40;
    hplot_v(val,cnt_a+i,'vr',i);
    a(end+1)=mean(eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 & eyelink.long==1))
    b(end+1)=mean(eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 & eyelink.long==1))
    hline(a(end),'b')
    hline(b(end),'r')
end
plot(a,'b');
plot(b,'r');
set(gca,'xtick',[1:12]);
set(gca,'xticklabel',subject(:,1:2));
axis auto;ylim([0 100])
fig(9)
subplot(1,2,2)
%ttest_bcoe(b,a)
mann_whitney(b,a)

fig(10);clf;set(gcf,'name','Eyelink2 Subject''s SRTs (pro v anti)')
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
fig(11);clf;set(gcf,'name','Eyelink2 Subject''s SRRs (pro v anti)')
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
for i=1:max(eyelink.subjectnum)
    fig(10);
    subplot(2,max(eyelink.subjectnum)/2,i)
    ttest_bcoe(eyelink.srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 ), eyelink.srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 ));
    xlabel(subject(i,1:2))   
    fig(11);
    subplot(2,max(eyelink.subjectnum)/2,i)
    mann_whitney(eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0 ), eyelink.rank_srt(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0 ));
    xlabel(subject(i,1:2))
end



fig(12);clf;hold on;ylim([200 1200])
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
set(gcf,'Name','All Blocks');
Ylabel('Saccadic Reaction Time')
[a b]=hist_b(eyelink.filenum);
temp=b(a>1);

a=[];b=[];
for i = 1:length(eyelink.file_name);
    xlim([i-.5 i+.5]);
    vline(i);
    [cnt val]=hist_b(eyelink.srt(eyelink.filenum==temp(i) & eyelink.anti==0 & eyelink.error==0 ),25);
    cnt_a=cnt/10;
    hplot_v(val,-cnt_a+i,'vb',i);
    [cnt val]=hist_b(eyelink.srt(eyelink.filenum==temp(i) & eyelink.anti==1 & eyelink.error==0 ),25);
    cnt_a=cnt/10;
    hplot_v(val,cnt_a+i,'vr',i);
    a(end+1)=mean(eyelink.srt(eyelink.filenum==temp(i) & eyelink.anti==0 & eyelink.error==0));
    b(end+1)=mean(eyelink.srt(eyelink.filenum==temp(i) & eyelink.anti==1 & eyelink.error==0));
    hline(a(end),'b');
    hline(b(end),'r');
    i=i+1;
end
plot(a,'b');
plot(b,'r');
set(gca,'xtick',1:length(eyelink.file_name));
set(gca,'xticklabel',eyelink.file_name);
set(gcf,'name','Eyelink2 Behavioral Data - - block by block');
axis tight;ylim([275 1025]);
fig(14),clf;
subplot(1,2,1);
ttest_bcoe(b,a);

fig(13);clf;hold on;ylim([0 100]);
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 scnsize(4)/2-30 0 0]));
set(gcf,'Name','All Blocks');
Ylabel('normalized Saccadic Reaction Rank');
a=[];b=[];
for i = 1:length(eyelink.file_name);
    xlim([i-.5 i+.5]);
    vline(i);
    [cnt val]=hist_b(eyelink.rank_srt(eyelink.filenum==temp(i) & eyelink.anti==0 & eyelink.error==0 ),25);
    cnt_a=cnt/10;
    hplot_v(val,-cnt_a+i,'vb',i);
    [cnt val]=hist_b(eyelink.rank_srt(eyelink.filenum==temp(i) & eyelink.anti==1 & eyelink.error==0 ),25);
    cnt_a=cnt/10;
    hplot_v(val,cnt_a+i,'vr',i);
    a(end+1)=mean(eyelink.rank_srt(eyelink.filenum==temp(i) & eyelink.anti==0 & eyelink.error==0));
    b(end+1)=mean(eyelink.rank_srt(eyelink.filenum==temp(i) & eyelink.anti==1 & eyelink.error==0));
    hline(a(end),'b');
    hline(b(end),'r');
end
plot(a,'b');
plot(b,'r');
set(gca,'xtick',1:length(eyelink.file_name));
set(gca,'xticklabel',eyelink.file_name);
set(gcf,'name','Eyelink2 Behavioral Data - - block by block');
axis tight;ylim([0 100]);
fig(14);
subplot(1,2,2);
ttest_bcoe(b,a);





fig(15);clf;set(gcf,'name','Eyelink2 Correct v Error Data (subject)');
set(gcf,'Position',round(scnsize.*[1 1 1 .45]+[3 30 0 0]));
tickout;
fred=[];
for i = 1:max(eyelink.subjectnum)
    pro_o =sum(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==0);
    pro_x =sum(eyelink.subjectnum==i & eyelink.anti==0 & eyelink.error==3);
    anti_o=sum(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==0);
    anti_x=sum(eyelink.subjectnum==i & eyelink.anti==1 & eyelink.error==3);
    nb_trials=sum(eyelink.subjectnum==i & eyelink.anti==0);
    fred=[fred; pro_o/nb_trials pro_x/nb_trials anti_o/nb_trials anti_x/nb_trials] ;
end
bar(fred);
xlim([.5 max(eyelink.subjectnum)+.5])
set(gca,'xtick',1:max(eyelink.subjectnum));
set(gca,'xticklabel',subject(:,1:2));
Xlabel('Subject')
Ylabel('% Correct/Incorrect')





fig(16),clf;set(gcf,'name','Delay effect on SRT - long (culmulative)')
fig(17),clf;set(gcf,'name','Delay effect on SRT - long')
subplot(3,1,1);hold on;title('Delay effect on SRT (long trials)')
for i=0:.5:1
    subplot(3,1,1);tickout
    pro_fred=eyelink.srt(eyelink.anti==0 & eyelink.error==0 & eyelink.delay==i  & eyelink.long==1 )
    xlim([i-.25 i+.25]);
    hline(mean(pro_fred),'b')
%     h=text(ones(size(pro_fred))*i-.04, pro_fred,'p');
%     set(h,'color',[0 0 1],'FontWeight','bold')
    [cnt val]=hist_b(pro_fred,25)
    cnt_a=cnt/200;
    hplot_v(val,-cnt_a+i,'vb',i)
    fig(16);
    hplot(val,(cumsum(cnt)/sum(cnt)*.5)+i,'b')
    fig(17);

    anti_fred=eyelink.srt(eyelink.anti==1 & eyelink.error==0 & eyelink.delay==i & eyelink.long==1 )
    hline(mean(anti_fred),'r')
%     h=text(ones(size(anti_fred))*i+.02, anti_fred,'a');
%     set(h,'color',[1 0 0],'FontWeight','bold')
    [cnt val]=hist_b(anti_fred,25)
    cnt_a=cnt/200;
    hplot_v(val,cnt_a+i,'vr',i)
    axis([-.25 1.25 200 1400])
    vline(i);
    fig(16);
    hplot(val,(cumsum(cnt)/sum(cnt)*.5)+i,'r')
    fig(17);
    
    subplot(3,3,(i/.5)+4);tickout
    ttest_bcoe(anti_fred,pro_fred)
    subplot(3,3,(i/.5)+7)
    mann_whitney(anti_fred,pro_fred)
end
fig(16);





fig(18),clf;set(gcf,'name','Delay effect on SRR - long (culmulative)')
fig(19),clf;set(gcf,'name','Delay effect on SRR - long')
subplot(3,1,1);hold on;title('Delay effect on SRR (long trials)')
for i=0:.5:1
    subplot(3,1,1);tickout
    pro_fred=eyelink.rank_srt(eyelink.anti==0 & eyelink.error==0 & eyelink.delay==i  & eyelink.long==1 )
    xlim([i-.25 i+.25]);
    hline(mean(pro_fred),'b')
%     h=text(ones(size(pro_fred))*i-.04, pro_fred,'p');
%     set(h,'color',[0 0 1],'FontWeight','bold')
    [cnt val]=hist_b(pro_fred,5)
    cnt_a=cnt/200;
    hplot_v(val,-cnt_a+i,'vb',i)
    fig(18);
    hplot(val,(cumsum(cnt)/sum(cnt)*.5)+i,'b')
    fig(19);

    anti_fred=eyelink.rank_srt(eyelink.anti==1 & eyelink.error==0 & eyelink.delay==i & eyelink.long==1 )
    hline(mean(anti_fred),'r')
%     h=text(ones(size(anti_fred))*i+.02, anti_fred,'a');
%     set(h,'color',[1 0 0],'FontWeight','bold')
    [cnt val]=hist_b(anti_fred,5)
    cnt_a=cnt/200;
    hplot_v(val,cnt_a+i,'vr',i)
    axis([-.25 1.25 -5 105])
    vline(i);
    fig(18);
    hplot(val,(cumsum(cnt)/sum(cnt)*.5)+i,'r')
    fig(19);
    
    subplot(3,3,(i/.5)+4);tickout
    ttest_bcoe(anti_fred,pro_fred)
    subplot(3,3,(i/.5)+7)
    mann_whitney(anti_fred,pro_fred)
end
fig(18);




save('eyelink','eyelink')
disp('eyelink2_behavioral_anaysis02')
return
